package com.kerbores.mongo.demo;

import java.util.Date;

import com.kerbores.mongo.EntityMapping;
import com.kerbores.mongo.SimpleEntityMapping;
import com.kerbores.mongo.dao.IMongoDao;
import com.kerbores.mongo.dao.MongoDao;
import com.kerbores.mongo.utils.Mongos;
import com.mongodb.DBCollection;

/**
 * @author Kerbores<br>
 *
 *         create at 2014年11月13日 下午10:36:55
 */
public class DEMO {

	public static class User {
		private long id;
		private String name;
		private String pwd;
		private Date birthDay;

		/**
		 * @return the id
		 */
		public long getId() {
			return id;
		}

		/**
		 * @param id
		 *            the id to set
		 */
		public void setId(long id) {
			this.id = id;
		}

		/**
		 * @return the name
		 */
		public String getName() {
			return name;
		}

		/**
		 * @param name
		 *            the name to set
		 */
		public void setName(String name) {
			this.name = name;
		}

		/**
		 * @return the pwd
		 */
		public String getPwd() {
			return pwd;
		}

		/**
		 * @param pwd
		 *            the pwd to set
		 */
		public void setPwd(String pwd) {
			this.pwd = pwd;
		}

		/**
		 * @return the birthDay
		 */
		public Date getBirthDay() {
			return birthDay;
		}

		/**
		 * @param birthDay
		 *            the birthDay to set
		 */
		public void setBirthDay(Date birthDay) {
			this.birthDay = birthDay;
		}

	}

	public static interface IUserDao extends IMongoDao<User> {
	}

	public static class UserDaoImpl extends MongoDao<User> implements IUserDao {

		/*
		 * (non-Javadoc)
		 * 
		 * @see com.kerbores.mongo.dao.MongoDao#getMapping()
		 */
		@Override
		protected EntityMapping<User> getMapping() {
			return new SimpleEntityMapping<User>(User.class);
		}

		/*
		 * (non-Javadoc)
		 * 
		 * @see com.kerbores.mongo.dao.MongoDao#getCollection()
		 */
		@Override
		protected DBCollection getCollection() {
			return Mongos.getCollection(User.class);
		}

	}

}
